<!-- 
SELECT id, min(`bid`) FROM `bids` 
WHERE `order_id`=2 AND `user_id`=42


SELECT *, min(bids.bid)
FROM  `orders` 
LEFT JOIN bids ON bids.order_id = orders.id
WHERE bids.user_id =42
GROUP BY bids.order_id

-->
<?php 
$won_orders = $mvc->getObject(OrdersService::BOUGHT_ORDERS);
$won_orders_archiv = $mvc->getObject(OrdersService::BOUGHT_ORDERS . '_archiv');
$bookmarks = $mvc->getObject(OrdersService::ORDER_BOOKMARKS);
$crnt_orders = $mvc->getObject(OrdersService::BIDS);
?>

<h2>_i18n{Orders Won}</h2>
<div class="unitABlock">
	<table cellpadding="0" cellspacing="0" class="viewList">
		<thead>
			<tr>
				<th class="itemChk"></th>
				<th>_i18n{Order-No}</th>
				<th>_i18n{Category}</th>
				<th>_i18n{Job Name}</th>
				<th>_i18n{End price}</th>
				<th>_i18n{User}</th>
				<th class="itemLast">_i18n{Date}</th>
			</tr>
		</thead>
		<tbody>
			<?php if (isset($won_orders)&& $won_orders!=NULL){?>
			<?php foreach($won_orders as $key => $won_order){?>
			<tr>
				<td><input type="checkbox" class="inpChk" name="chkM" value="<?php echo $won_order[OrdersService::HASH];?>" /></td>
				<td><?php echo $won_order[OrdersService::ID];?></td>
				<td><?php echo $won_order[CategoryService::CAT_NAME];?></td>
				<td><a class="linkTr" href="view-order.html?id=<?php echo $won_order[OrdersService::HASH];?>" title="<?php echo $won_order[OrdersService::ORDER_DESC];?>"><?php echo $won_order[OrdersService::ORDER_NAME];?></a></td>
				<td><?php echo $won_order[OrdersService::BOUGHT_PRICE];?> &euro;</td>
				<td><?php echo $won_order[UsersService::USERNAME];?></td>
				<td class="itemLast"><?php echo $won_order[OrdersService::BOUGHT_DATE];?></td>
			</tr>
			<?php } } ?>
		</tbody>
	</table>
</div>
<h2>_i18n{Review Current Bids}</h2>
<div class="unitABlock">
	<table cellpadding="0" cellspacing="0" class="viewList">
		<thead>
			<tr>
				<th class="itemChk"></th>
				<th>_i18n{Order-No}</th>
				<th>_i18n{Category}</th>
				<th>_i18n{Job Name}</th>
				<th>_i18n{User}</th>
				<th>_i18n{Price}</th>
				<th class="itemLast">_i18n{My Bid}</th>
			</tr>
		</thead>
		<tbody>
			<?php if (isset($crnt_orders)&& $crnt_orders!=NULL){?>
			<?php foreach($crnt_orders as $key => $crnt_order){?>
			<tr>
				<td><input type="checkbox" class="inpChk" name="chkM" value="<?php echo $crnt_order[OrdersService::HASH];?>" /></td>
				<td><?php echo $crnt_order[OrdersService::ID];?></td>
				<td><?php echo $crnt_order[CategoryService::CAT_NAME];?></td>
				<td><a class="linkTr" href="view-order.html?id=<?php echo $crnt_order[OrdersService::HASH];?>" title="<?php echo $crnt_order[OrdersService::ORDER_NAME];?>"><?php echo $crnt_order[OrdersService::ORDER_NAME];?></a></td>
				<td><?php echo $crnt_order[UsersService::USERNAME];?></td>
				<td><?php echo $crnt_order[OrdersService::PRICE];?> &euro;</td>
				<td class="itemLast"><?php echo $crnt_order[OrdersService::BIDS];?> &euro;	</td>
			</tr>
			<?php } } ?>
		</tbody>
	</table>
</div>
<h2>_i18n{Bookmarks / Alerts}</h2>
<div class="unitABlock">
	<table cellpadding="0" cellspacing="0" class="viewList">
		<thead>
			<tr>
				<th class="itemChk"></th>
				<th>_i18n{Order-No}</th>
				<th>_i18n{Category}</th>
				<th>_i18n{Job Name}</th>
				<th>_i18n{Price}</th>
				<th class="itemLast">_i18n{User}</th>
			</tr>
		</thead>
		<tbody>
		<?php if (isset($bookmarks)&& $bookmarks!=NULL){?>
		<?php foreach($bookmarks as $key => $bookmark){?>
			<tr>
				<td><input type="checkbox" class="inpChk" name="chkM" value="<?php echo $bookmark[OrdersService::HASH];?>" /></td>
				<td><?php echo $bookmark[OrdersService::ID];?></td>
				<td><?php echo $bookmark[CategoryService::CAT_NAME];?></td>
				<td><a class="linkTr" href="view-order.html?id=<?php echo $bookmark[OrdersService::HASH];?>" title="<?php echo $bookmark[OrdersService::ORDER_NAME];?>"><?php echo $bookmark[OrdersService::ORDER_NAME];?></a></td>
				<td><?php echo $bookmark[OrdersService::PRICE];?> &euro;</td>
				<td class="itemLast"><?php echo $bookmark[UsersService::USERNAME];?></td>
			</tr>
		<?php } } ?>
		</tbody>
	</table>
</div>

<h2>_i18n{Orders Archive}</h2>
<div class="unitABlock">
	<table cellpadding="0" cellspacing="0" class="viewList">
		<thead>
			<tr>
				<th class="itemChk"></th>
				<th>_i18n{Order-No}</th>
				<th>_i18n{Category}</th>
				<th>_i18n{Job Description}</th>
				<th>_i18n{User}</th>
				<th>_i18n{Price}</th>
				<th>_i18n{My Bid}</th>
				<th class="itemLast">_i18n{Date}</th>
			</tr>
		</thead>
		<tbody>
			<tr>
				<td><input type="checkbox" class="inpChk" name="chkM" value="" /></td>
				<td><a class="linkTr" href="#" title="A230">A230</a></td>
				<td>Kategorie1</td>
				<td>Beschreib...</td>
				<td>user17</td>
				<td>123.00 &euro;</td>
				<td>130.00 &euro;</td>
				<td class="itemLast">01/03/2010</td>
			</tr>
		</tbody>
	</table>
</div>
<h2>_i18n{Won Orders Archive}</h2>
<div class="unitABlock unitABlockLast">
	<table cellpadding="0" cellspacing="0" class="viewList">
		<thead>
			<tr>
				<th class="itemChk"></th>
				<th>_i18n{Order-No}</th>
				<th>_i18n{Category}</th>
				<th>_i18n{Job Name}</th>
				<th>_i18n{End price}</th>
				<th>_i18n{User}</th>
				<th class="itemLast">_i18n{Date}</th>
			</tr>
		</thead>
		<tbody>
			<?php if (isset($won_orders_archiv)&& $won_orders_archiv!=NULL){?>
			<?php foreach($won_orders_archiv as $key => $won_order_archiv){?>
			<tr>
				<td><input type="checkbox" class="inpChk" name="chkM" value="<?php echo $won_order_archiv[OrdersService::HASH];?>" /></td>
				<td><?php echo $won_order_archiv[OrdersService::ID];?></td>
				<td><?php echo $won_order_archiv[CategoryService::CAT_NAME];?></td>
				<td><a class="linkTr" href="view-order.html?id=<?php echo $won_order_archiv[OrdersService::HASH];?>" title="<?php echo $won_order_archiv[OrdersService::ORDER_DESC];?>"><?php echo $won_order_archiv[OrdersService::ORDER_NAME];?></a></td>
				<td><?php echo $won_order_archiv[OrdersService::BOUGHT_PRICE];?> &euro;</td>
				<td><?php echo $won_order_archiv[UsersService::USERNAME];?></td>
				<td class="itemLast"><?php echo $won_order_archiv[OrdersService::BOUGHT_DATE];?></td>
			</tr>
			<?php } } ?>
		</tbody>
	</table>
</div>